{% extends "layout.html" %}
{% block content %}

<div class="row-fluid">
  <div class="span12">
    <div class="light-green-header no_20_margin">
      <h3 class="text_shadow_light">Shortest queue {% if shortest_queue %}<span class="badge badge-warning">{{ shortest_queue.orders_in_queue() }} in queue</span>{% endif %}</h3>
    </div>
    <div id="featured_food" class="no_20_margin">
      <div class="featured_food_intro">
        {% if shortest_queue  %}
          <p class="pull-left">
            {{ shortest_queue.food.name }}<br/>
            <i>{{ shortest_queue.truck.name }}</i><br/>
            <small>Est. time: {{ shortest_queue.average_wait_time() }}</small>
          </p>
          <a class="btn pull-right" href="{{ url_for('truck_detail',truck_id = shortest_queue.truck.id) }}">Order this</a>
        {% else %}
        <p>No orders placed today</p>
        {% endif %}
        <div class="clearfix"></div>
      </div>
    </div>

    <div class="light-green-header no_20_margin">
      <h3 class="text_shadow_light">Most ordered {% if most_ordered %}<span class="badge badge-warning">{{ most_ordered.orders_in_queue() }} ordered</span>{% endif %}</h3>
    </div>
    <div id="" class="no_20_margin">
      <div class="featured_food_intro">
        {% if most_ordered %}
          <p class="pull-left">
            {{ most_ordered.food.name }}<br/>
            <i>{{ most_ordered.truck.name }}</i><br/>
            <small>Est. time: {{ most_ordered.average_wait_time() }}</small>
          </p>
          <a class="btn pull-right" href="{{ url_for('truck_detail',truck_id = most_ordered.truck.id) }}">Order this</a>
        {% else %}
        <p>No orders placed today</p>
        {% endif %}
        <div class="clearfix"></div>
      </div>
    </div>

    <div class="light-green-header no_20_margin">
      <h3 class="text_shadow_light">Lowest stock {% if lowest_stock %}<span class="badge badge-warning">{{ lowest_stock.remaining_orders() }} left</span>{% endif %}</h3>
    </div>
    <div id="" class="no_20_margin">
      <div class="featured_food_intro">
        {% if lowest_stock %}
          <p class="pull-left">
            {{ lowest_stock.food.name }}<br/>
            <i>{{ lowest_stock.truck.name }}</i><br/>
            <small>Est. time: {{ lowest_stock.average_wait_time() }}</small>
          </p>
          <a class="btn pull-right" href="{{ url_for('truck_detail',truck_id = lowest_stock.truck.id) }}">Order this</a>
        {% else %}
        <p>No orders placed today</p>
        {% endif %}
        <div class="clearfix"></div>
      </div>
    </div>
  </div>
</div>

<div class="row-fluid">
  <div class="span12">
    <div class="light-green-header no_20_margin">
      <h3 class="text_shadow_light">Your orders</h3>
    </div>
    {% if pending_orders and (pending_orders | count) >0 %}
      <div class="iphone_style_list_wrapper">
        <ul class="iphone_style_list">
          {% for o in pending_orders %}
            <li {% if o.status == o.STATUS_READY %}class='ready_order'{% endif %}>
              <a class="" href="{{ url_for('order_detail', order_id = o.id)}}">
                {{ o.menu_item.food.name }}
                <span class="time_left pull-right">
                  {% if o.status == o.STATUS_READY %}
                    READY
                  {% else %}
                    {{ o.menu_item.orders_in_queue() - 1 }} before you
                  {% endif %}
                </span>
              </a>
            </li>
          {% endfor %}
        </ul>
      </div>
    {% else %}
      <p class="white-text">You have no orders. Why don't you <a href="{{ url_for('trucks') }}">place one</a>?</p>
    {% endif %}
  </div>
</div>
{% endblock %}